package com.wang.demo02;


//UserServiceIml的代理（未改变原有代码增加了日志功能）
public class UserServiceProxy implements UserService{

    private UserServiceIml userServiceIml;

    public void setUserServiceIml(UserServiceIml userServiceIml) {
        this.userServiceIml = userServiceIml;
    }

    public void add() {
        log("add");
        userServiceIml.add();
    }

    public void delete() {
        log("delete");
        userServiceIml.delete();
    }

    public void update() {
        log("update");
        userServiceIml.update();
    }

    public void query() {
        log("query");
        userServiceIml.query();
    }

    //在不改变原代码的基础可以随意添加额外代码：比如日志

    public void log(String msg){
        System.out.println("使用了"+msg+"方法");
    }
}
